# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gss
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
pkgver=1.0.3
pkgrel=1
pkgdesc="GNU Generic Security Service (mingw-w64)"
arch=('any')
url="https://www.gnu.org/software/gss/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "git" "wget" "texinfo")
options=('strip' 'staticlibs')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-shishi")
source=(https://ftp.gnu.org/gnu/gss/${_realname}-${pkgver}.tar.gz{,.sig}
        001-autoconf.patch
        002-gnulib.patch)
sha256sums=('ff919ddc731531d65e27d7ababdc361aae05ada5f1a6dd60703d153307dcdeeb'
            'SKIP'
            'eb2bfe34d3ad1cc1292f087b527be4402e471ad881a73ea18de3579f4ce85a3c'
            '3fc80ab5f4836ce2ca3ac8311e62d51e33c43adfeec7d69120a999076ccf7b81')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-autoconf.patch
  patch -p1 -i ${srcdir}/002-gnulib.patch
  touch doc/Makefile.gdoc

  WANT_AUTOMAKE=latest autoreconf -fi

}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make -j1
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
}
